Carpenter's Complete Guide to the SAS Macro Language, Third Edition by Art Carpenter

Carpenter's Complete Guide to the SAS Macro Language, Third Edition by Art Carpenter

Author:Art Carpenter [Carpenter, Art]
Language: eng
Format: epub, pdf
Publisher: SAS Institute
Published: 2016-08-24T16:00:00+00:00


10.5.1 The Macro Library Search Order

As these libraries of macros are established it is important for both the developer and the user to understand the relationship between them. One of the more important aspects of this relationship is the order of locations that SAS searches for a macro definition.

When a macro is called, the macro facility must first find the macro definition before it can be compiled and executed. Since the macro definition can be stored in any of several locations, the developer needs to be able to control the search. The search for the macro definition uses the following order:

1. WORK.SASMACR

2. Stored compiled macros (when they are turned on)

3. Autocall macros

The first time that a macro is called it will not be found in any of the catalogs of compiled macros, but once it is called, it will be compiled and the compiled code will be stored (in WORK.SASMACR unless otherwise specified). On successive calls to that macro, its compiled definition will be found and the search will not extend to the autocall library a second time. This process minimizes the compilation of the macro.

This is a major advantage over the use of %INCLUDE as a macro library. When a macro definition is brought into the program through %INCLUDE, it will be compiled for each %INCLUDE. Of course, if the programmer is careful, this is not such a bad thing. If the %INCLUDE appears only once, the macro will be compiled at that time and added to the WORK.SASMACR catalog, and the compiled macro definition will be used from then on (as long as it is not included another time).

Macros in the autocall libraries are never inspected by the SAS Macro Facility until the macro is called. The macro is then compiled (and its compiled version is loaded into WORK.SASMACR) and executed.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.